/*
 * Exploder
 * 
 * Tero Pyylampi (218437), Jussi Tuurinkoski (211594)
 *
 * An engine for updating all the physic objects in the game
 */

#include "GameInterfaceEngine.h"
#include "GameInterfaceObject.h"
#include "GameInterfaceEditorContainer.h"
#include "GameInterfaceGameContainer.h"

// default constructor
GameInterfaceEngine::GameInterfaceEngine() : GameAbstractEngine(), mInterfaceObjects( 0 ), mEditorContainer( 0 ) {
	mInterfaceObjects = new std::vector< GameInterfaceObject* >();
}

// default destructor
GameInterfaceEngine::~GameInterfaceEngine() {
	for( unsigned int i = 0; i < mInterfaceObjects->size(); ++i )
		delete mInterfaceObjects->at( i );
	delete mInterfaceObjects;
}

// update engine state
void GameInterfaceEngine::update( cocos2d::ccTime dt ) {
	for( unsigned int i = 0; i < mInterfaceObjects->size(); ++i ) {
		mInterfaceObjects->at( i )->update( dt );
	}
}

// create interface for game mode
void GameInterfaceEngine::createGameModeInterface( cocos2d::CCLayer *layer, MainEngine *mainEngine, GameScene *gameScene ) {
	mGameScene = gameScene;

	// create container
	mGameContainer = new GameInterfaceGameContainer( layer, mainEngine, gameScene );
	mInterfaceObjects->push_back( mGameContainer );
}

// create interface for editor mode
void GameInterfaceEngine::createEditorModeInterface( cocos2d::CCLayer *layer, MainEngine *mainEngine, EditorScene *editorScene ) {
	mEditorScene = editorScene;

	// create editor container
	mEditorContainer = new GameInterfaceEditorContainer( layer, mainEngine, editorScene );
	mInterfaceObjects->push_back( mEditorContainer );
}

// get objects
std::vector< GameInterfaceObject* > *GameInterfaceEngine::getInterfaceObjects() {
	return mInterfaceObjects;
}

// get game container
GameInterfaceGameContainer *GameInterfaceEngine::getGameContainer() {
	return mGameContainer;
}

// get editor container
GameInterfaceEditorContainer *GameInterfaceEngine::getEditorContainer() {
	return mEditorContainer;
}
